package rabbitMQStudy;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

/**
 * Project: tobe-better-coder
 * Package: rabbitMQStudy
 *
 * @author : Mr.xu
 * @date : 2023/5/6 8:00
 */
public class CommonUtil {

    //创建一个消息连接工厂
    static ConnectionFactory factory = new ConnectionFactory();

    static {
        factory.setHost("localhost");
        factory.setUsername("guest");
        factory.setPassword("guest");
    }

    public static Channel getChannel() throws IOException, TimeoutException {


        return factory.newConnection().createChannel();
    }
}